<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QHttpHeader Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QHttpHeader Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QHttpHeader class contains header information for HTTP.
<a href="#details">More...</a></p>

<p>Inherited by <a href="qhttprequestheader.html">QHttpRequestHeader</a> and <a href="qhttpresponseheader.html">QHttpResponseHeader</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qhttpheader.html#QHttpHeader">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#QHttpHeader-2">__init__</a></b> (<i>self</i>, QHttpHeader&#160;<i>header</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#QHttpHeader-3">__init__</a></b> (<i>self</i>, QString&#160;<i>str</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#addValue">addValue</a></b> (<i>self</i>, QString&#160;<i>key</i>, QString&#160;<i>value</i>)</li><li><div class="fn" />QStringList <b><a href="qhttpheader.html#allValues">allValues</a></b> (<i>self</i>, QString&#160;<i>key</i>)</li><li><div class="fn" />int <b><a href="qhttpheader.html#contentLength">contentLength</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qhttpheader.html#contentType">contentType</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#hasContentLength">hasContentLength</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#hasContentType">hasContentType</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#hasKey">hasKey</a></b> (<i>self</i>, QString&#160;<i>key</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />QStringList <b><a href="qhttpheader.html#keys">keys</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qhttpheader.html#majorVersion">majorVersion</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qhttpheader.html#minorVersion">minorVersion</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#parse">parse</a></b> (<i>self</i>, QString&#160;<i>str</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#parseLine">parseLine</a></b> (<i>self</i>, QString&#160;<i>line</i>, int&#160;<i>number</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#removeAllValues">removeAllValues</a></b> (<i>self</i>, QString&#160;<i>key</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#removeValue">removeValue</a></b> (<i>self</i>, QString&#160;<i>key</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#setContentLength">setContentLength</a></b> (<i>self</i>, int&#160;<i>len</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#setContentType">setContentType</a></b> (<i>self</i>, QString&#160;<i>type</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#setValid">setValid</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qhttpheader.html#setValue">setValue</a></b> (<i>self</i>, QString&#160;<i>key</i>, QString&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#setValues">setValues</a></b> (<i>self</i>, list-of-tuple-of-QString-QString&#160;<i>values</i>)</li><li><div class="fn" />QString <b><a href="qhttpheader.html#toString">toString</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qhttpheader.html#value">value</a></b> (<i>self</i>, QString&#160;<i>key</i>)</li><li><div class="fn" />list-of-tuple-of-QString-QString <b><a href="qhttpheader.html#values">values</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QHttpHeader class contains header information for HTTP.</p>
<p>In most cases you should use the more specialized derivatives of
this class, <a href="qhttpresponseheader.html">QHttpResponseHeader</a> and <a href="qhttprequestheader.html">QHttpRequestHeader</a>, rather than
directly using QHttpHeader.</p>
<p>QHttpHeader provides the HTTP header fields. A HTTP header field
consists of a name followed by a colon, a single space, and the
field value. (See RFC 1945.) Field names are case-insensitive. A
typical header field looks like this:</p>
<pre class="cpp">
 content<span class="operator">-</span>type: text<span class="operator">/</span>html
</pre>
<p>In the API the header field name is called the "key" and the
content is called the "value". You can get and set a header field's
value by using its key with <a href="qhttpheader.html#value">value</a>() and <a href="qhttpheader.html#setValue">setValue</a>(), e.g.</p>
<pre class="cpp">
 header<span class="operator">.</span><a href="qhttpheader.html#setValue">setValue</a>(<span class="string">"content-type"</span><span class="operator">,</span> <span class="string">"text/html"</span>);
 <span class="type"><a href="qstring.html">QString</a></span> contentType <span class="operator">=</span> header<span class="operator">.</span><a href="qhttpheader.html#value">value</a>(<span class="string">"content-type"</span>);
</pre>
<p>Some fields are so common that getters and setters are provided
for them as a convenient alternative to using <a href="qhttpheader.html#value">value</a>() and <a href="qhttpheader.html#setValue">setValue</a>(), e.g. <a href="qhttpheader.html#contentLength">contentLength</a>() and <a href="qhttpheader.html#contentType">contentType</a>(), <a href="qhttpheader.html#setContentLength">setContentLength</a>() and
<a href="qhttpheader.html#setContentType">setContentType</a>().</p>
<p>Each header key has a <i>single</i> value associated with it. If
you set the value for a key which already exists the previous value
will be discarded.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QHttpHeader" />QHttpHeader.__init__ (<i>self</i>)</h3><p>Constructs an empty HTTP header.</p>


<h3 class="fn"><a name="QHttpHeader-2" />QHttpHeader.__init__ (<i>self</i>, <a href="qhttpheader.html">QHttpHeader</a>&#160;<i>header</i>)</h3><p>Constructs a copy of <i>header</i>.</p>


<h3 class="fn"><a name="QHttpHeader-3" />QHttpHeader.__init__ (<i>self</i>, QString&#160;<i>str</i>)</h3><p>Constructs a HTTP header for <i>str</i>.</p>
<p>This constructor parses the string <i>str</i> for header fields
and adds this information. The <i>str</i> should consist of one or
more "\r\n" delimited lines; each of these lines should have the
format key, colon, space, value.</p>


<h3 class="fn"><a name="addValue" />QHttpHeader.addValue (<i>self</i>, QString&#160;<i>key</i>, QString&#160;<i>value</i>)</h3><p>Adds a new entry with the <i>key</i> and <i>value</i>.</p>


<h3 class="fn"><a name="allValues" />QStringList QHttpHeader.allValues (<i>self</i>, QString&#160;<i>key</i>)</h3><p>Returns all the entries with the given <i>key</i>. If no entry
has this <i>key</i>, an empty string list is returned.</p>


<h3 class="fn"><a name="contentLength" />int QHttpHeader.contentLength (<i>self</i>)</h3><p>Returns the value of the special HTTP header field
<tt>content-length</tt>.</p>
<p><b>See also</b> <a href="qhttpheader.html#setContentLength">setContentLength</a>() and
<a href="qhttpheader.html#hasContentLength">hasContentLength</a>().</p>


<h3 class="fn"><a name="contentType" />QString QHttpHeader.contentType (<i>self</i>)</h3><p>Returns the value of the special HTTP header field
<tt>content-type</tt>.</p>
<p><b>See also</b> <a href="qhttpheader.html#setContentType">setContentType</a>() and <a href="qhttpheader.html#hasContentType">hasContentType</a>().</p>


<h3 class="fn"><a name="hasContentLength" />bool QHttpHeader.hasContentLength (<i>self</i>)</h3><p>Returns true if the header has an entry for the special HTTP
header field <tt>content-length</tt>; otherwise returns false.</p>
<p><b>See also</b> <a href="qhttpheader.html#contentLength">contentLength</a>() and <a href="qhttpheader.html#setContentLength">setContentLength</a>().</p>


<h3 class="fn"><a name="hasContentType" />bool QHttpHeader.hasContentType (<i>self</i>)</h3><p>Returns true if the header has an entry for the special HTTP
header field <tt>content-type</tt>; otherwise returns false.</p>
<p><b>See also</b> <a href="qhttpheader.html#contentType">contentType</a>() and <a href="qhttpheader.html#setContentType">setContentType</a>().</p>


<h3 class="fn"><a name="hasKey" />bool QHttpHeader.hasKey (<i>self</i>, QString&#160;<i>key</i>)</h3><p>Returns true if the HTTP header has an entry with the given
<i>key</i>; otherwise returns false.</p>
<p><b>See also</b> <a href="qhttpheader.html#value">value</a>(),
<a href="qhttpheader.html#setValue">setValue</a>(), and <a href="qhttpheader.html#keys">keys</a>().</p>


<h3 class="fn"><a name="isValid" />bool QHttpHeader.isValid (<i>self</i>)</h3><p>Returns true if the HTTP header is valid; otherwise returns
false.</p>
<p>A <a class="obsolete" href="qhttpheader.html">QHttpHeader</a> is
invalid if it was created by parsing a malformed string.</p>


<h3 class="fn"><a name="keys" />QStringList QHttpHeader.keys (<i>self</i>)</h3><p>Returns a list of the keys in the HTTP header.</p>
<p><b>See also</b> <a href="qhttpheader.html#hasKey">hasKey</a>().</p>


<h3 class="fn"><a name="majorVersion" />int QHttpHeader.majorVersion (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the major protocol-version of the HTTP header.</p>


<h3 class="fn"><a name="minorVersion" />int QHttpHeader.minorVersion (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the minor protocol-version of the HTTP header.</p>


<h3 class="fn"><a name="parse" />bool QHttpHeader.parse (<i>self</i>, QString&#160;<i>str</i>)</h3><h3 class="fn"><a name="parseLine" />bool QHttpHeader.parseLine (<i>self</i>, QString&#160;<i>line</i>, int&#160;<i>number</i>)</h3><h3 class="fn"><a name="removeAllValues" />QHttpHeader.removeAllValues (<i>self</i>, QString&#160;<i>key</i>)</h3><p>Removes all the entries with the key <i>key</i> from the HTTP
header.</p>


<h3 class="fn"><a name="removeValue" />QHttpHeader.removeValue (<i>self</i>, QString&#160;<i>key</i>)</h3><p>Removes the entry with the key <i>key</i> from the HTTP
header.</p>
<p><b>See also</b> <a href="qhttpheader.html#value">value</a>() and
<a href="qhttpheader.html#setValue">setValue</a>().</p>


<h3 class="fn"><a name="setContentLength" />QHttpHeader.setContentLength (<i>self</i>, int&#160;<i>len</i>)</h3><p>Sets the value of the special HTTP header field
<tt>content-length</tt> to <i>len</i>.</p>
<p><b>See also</b> <a href="qhttpheader.html#contentLength">contentLength</a>() and <a href="qhttpheader.html#hasContentLength">hasContentLength</a>().</p>


<h3 class="fn"><a name="setContentType" />QHttpHeader.setContentType (<i>self</i>, QString&#160;<i>type</i>)</h3><p>Sets the value of the special HTTP header field
<tt>content-type</tt> to <i>type</i>.</p>
<p><b>See also</b> <a href="qhttpheader.html#contentType">contentType</a>() and <a href="qhttpheader.html#hasContentType">hasContentType</a>().</p>


<h3 class="fn"><a name="setValid" />QHttpHeader.setValid (<i>self</i>, bool)</h3><h3 class="fn"><a name="setValue" />QHttpHeader.setValue (<i>self</i>, QString&#160;<i>key</i>, QString&#160;<i>value</i>)</h3><p>Sets the value of the entry with the <i>key</i> to
<i>value</i>.</p>
<p>If no entry with <i>key</i> exists, a new entry with the given
<i>key</i> and <i>value</i> is created. If an entry with the
<i>key</i> already exists, the first value is discarded and
replaced with the given <i>value</i>.</p>
<p><b>See also</b> <a href="qhttpheader.html#value">value</a>(),
<a href="qhttpheader.html#hasKey">hasKey</a>(), and <a href="qhttpheader.html#removeValue">removeValue</a>().</p>


<h3 class="fn"><a name="setValues" />QHttpHeader.setValues (<i>self</i>, list-of-tuple-of-QString-QString&#160;<i>values</i>)</h3><p>Sets the header entries to be the list of key value pairs in
<i>values</i>.</p>
<p><b>See also</b> <a href="qhttpheader.html#values">values</a>().</p>


<h3 class="fn"><a name="toString" />QString QHttpHeader.toString (<i>self</i>)</h3><p>Returns a string representation of the HTTP header.</p>
<p>The string is suitable for use by the constructor that takes a
<a href="qstring.html">QString</a>. It consists of lines with the
format: key, colon, space, value, "\r\n".</p>


<h3 class="fn"><a name="value" />QString QHttpHeader.value (<i>self</i>, QString&#160;<i>key</i>)</h3><p>Returns the first value for the entry with the given <i>key</i>.
If no entry has this <i>key</i>, an empty string is returned.</p>
<p><b>See also</b> <a href="qhttpheader.html#setValue">setValue</a>(), <a href="qhttpheader.html#removeValue">removeValue</a>(), <a href="qhttpheader.html#hasKey">hasKey</a>(), and <a href="qhttpheader.html#keys">keys</a>().</p>


<h3 class="fn"><a name="values" />list-of-tuple-of-QString-QString QHttpHeader.values (<i>self</i>)</h3><p>Returns all the entries in the header.</p>
<p><b>See also</b> <a href="qhttpheader.html#setValues">setValues</a>().</p>


<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>